export default {
  data() {
    return {
      styles: {
        height: "calc(100% - 55px)",
        overflow: "auto",
        paddingBottom: "53px",
        position: "static",
      },
      formData: {},
      list: [],
      showInfo: false,
      columns: [
        {
          title: "联系人",
          key: "name",
          align: "center",
          fixed: "left",
          width: 150,
        },
        {
          title: "公司名称",
          key: "title",
          align: "center",
        },
        {
          title: "appKey",
          key: "appkey",
          align: "center",
        },
        {
            title: "appSecret",
            key: "appsecret",
            align: "center",
          },
        {
          title: "操作",
          key: "action",
          align: "center",
          width: 150,
          slot: "action",
          fixed: "right",
        },
      ],
    };
  },
  computed: {
    user() {
      return this.$store.state.user;
    },
  },
  methods: {
    addAction() {
      this.formData = {};
      this.showInfo = true;
    },
    edit(index) {
        var model = this.list[index];
        this.formData = Object.assign({},model);
        this.showInfo = true;
    },
    deleteInfo(index) {
        var model = this.list[index];
        var that = this;
        this.$Modal.confirm({
            title:"删除提示",
            content:`确认删除《${model.title}》的开发者信息么？`,
            onOk:()=> {
                this.$axios({
                    url: "/developer/" + model.serid,
                    method: "DELETE",
                  }).then((res) => {
                      if (res.code  == 200) {
                        this.$Message.info(res.data);
                        that.getData();
                      }else {
                        this.$Message.error(res.msg);
                      }
                  });
            }
        })
    },
    getData() {
      this.$axios({
        url: "/developer/list",
        method: "POST",
      }).then((res) => {
        this.list = res.data;
      });
    },
    saveInfo() {
      this.$axios({
        url: "/developer",
        method: "PUT",
        data: this.formData,
      }).then((res) => {
        if (res.code == 200) {
          this.$Message.info(res.data);
          this.showInfo = false;
          this.getData();
        } else {
          this.$Message.error(res.msg);
        }
      });
    },
  },
  created() {
    this.getData();
  },
};
